import { Request, toast, parseTime, formatTimeQuantity } from '../../../utils/util.js'
let request = new Request()
const app = getApp()
Page({
  data: {
    orderNo : ''
  },

  getOrder () {
    if (app.globalData.isLogin == false) {
      setTimeout(() => {
        this.getOrder()
      }, 2000)
      return
    }
    request.get('chargedetail', res => {
      if(res.success) {
        let order = res.data
        order.start_time = parseTime(order.start_time, '{y}-{m}-{d} {h}:{i}')
        order.end_time = parseTime(order.end_time, '{y}-{m}-{d} {h}:{i}')
        order.consume_time = formatTimeQuantity(order.consume_time)
        if(order.charge_type == 1) {
          order.charge_quantity = order.charge_quantity / 60 + '小时'
        }else{
          order.charge_quantity += '度'
        }
        this.setData({order : order})
      }
    }, { no: this.data.orderNo}).showLoading()
  },

  onLoad: function (options) {
    let orderNo = options.orderNo
    this.setData({ orderNo: orderNo})
    this.getOrder()
   
  }
})